# encoding: UTF-8
"""

@author = 李林名
@email = lishuai1199@qq.com
@create_time = 2022/11/24 16:33

"""

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep


#1.对checkbox点击:   先打印当前选中的老师的名字，再选择并打印小雷老师
wd = webdriver.Chrome()
wd.get('https://cdn2.byhy.net/files/selenium/test2.html')
##根据属性选择元素,并打印对应老师名
elements = wd.find_elements(By.CSS_SELECTOR, '#s_checkbox input[checked="checked"]')
for element in elements:
    print(element.get_attribute('value'))
    sleep(1)
    element.click()
##选择并打印小雷老师
element=wd.find_element(By.CSS_SELECTOR,'#s_checkbox input[value="小雷老师"]')
element.click()
print(element.get_attribute('value'))
sleep(1)
